package com.example.tliaswebmanagement.mapper;

import com.example.tliaswebmanagement.entity.Clazz;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ClazzMapper {

    List<Clazz> findAll(String name,LocalDate begin, LocalDate end);

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) " +
            "values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    @Select("select * from clazz where id=#{id}")
    Clazz findById(Integer id);

    void update(Clazz clazz);

    //获取所有班级信息
    @Select("select * from clazz")
    List<Clazz> getAll();
}
